package ihm;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JRadioButton;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.SQLException;

public class MenuAppli extends JFrame implements ActionListener
{

	private ButtonGroup btG;
	private JPanel contentPane;
	private JRadioButton rdbtnCrerUnSpectacle;
	private JRadioButton rdbtnCrerUnNumro;
	private JRadioButton rdbtnCrerUnArtiste;
	private JRadioButton rdbtnCrerUneSpcialit;
	private JLabel lblCirquePhys;
	private JButton btnQuitter;
	private JButton btnValider;
	private JRadioButton rdbtnAjouterUnNumro;
	private JRadioButton rdbtnAjouterUnArtiste;
	private JRadioButton rdbtnListerLesNumros;
	private JRadioButton rdbtnListerLesArtistes;
	private JRadioButton rdbtnoptionnelProgrammeDu;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) 
	{
		EventQueue.invokeLater(new Runnable() 
		{
			public void run() {
				try {
					MenuAppli frame = new MenuAppli();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public MenuAppli() {
		setTitle("Menu principal");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		rdbtnCrerUnSpectacle = new JRadioButton("Cr\u00E9er un spectacle");
		rdbtnCrerUnSpectacle.setBounds(6, 73, 115, 23);
		contentPane.add(rdbtnCrerUnSpectacle);
		
		rdbtnCrerUnNumro = new JRadioButton("Cr\u00E9er un num\u00E9ro");
		rdbtnCrerUnNumro.setBounds(6, 99, 115, 23);
		contentPane.add(rdbtnCrerUnNumro);
		
		rdbtnCrerUnArtiste = new JRadioButton("Cr\u00E9er un artiste");
		rdbtnCrerUnArtiste.setBounds(6, 125, 115, 23);
		contentPane.add(rdbtnCrerUnArtiste);
		
		rdbtnCrerUneSpcialit = new JRadioButton("Cr\u00E9er une sp\u00E9cialit\u00E9");
		rdbtnCrerUneSpcialit.setBounds(6, 151, 126, 23);
		contentPane.add(rdbtnCrerUneSpcialit);
		
		lblCirquePhys = new JLabel("Cirque Phys");
		lblCirquePhys.setFont(new Font("Arial Narrow", Font.BOLD | Font.ITALIC, 16));
		lblCirquePhys.setBounds(172, 21, 80, 23);
		contentPane.add(lblCirquePhys);
		
		btnQuitter = new JButton("Quitter");
		btnQuitter.addActionListener(this);
		btnQuitter.setBounds(322, 228, 91, 23);
		contentPane.add(btnQuitter);
		
		btnValider = new JButton("Valider");
		btnValider.addActionListener(this);
		btnValider.setBounds(214, 228, 91, 23);
		contentPane.add(btnValider);
		
		rdbtnAjouterUnNumro = new JRadioButton("Ajouter un num\u00E9ro \u00E0 un spectacle");
		rdbtnAjouterUnNumro.setBounds(190, 73, 223, 23);
		contentPane.add(rdbtnAjouterUnNumro);
		
		rdbtnAjouterUnArtiste = new JRadioButton("Ajouter un artiste \u00E0 un num\u00E9ro");
		rdbtnAjouterUnArtiste.setBounds(189, 99, 224, 23);
		contentPane.add(rdbtnAjouterUnArtiste);
		
		rdbtnListerLesNumros = new JRadioButton("Lister les num\u00E9ros d'un spectacle");
		rdbtnListerLesNumros.setBounds(190, 125, 223, 23);
		contentPane.add(rdbtnListerLesNumros);
		
		rdbtnListerLesArtistes = new JRadioButton("Lister les artistes d'un num\u00E9ro");
		rdbtnListerLesArtistes.setBounds(190, 151, 223, 23);
		contentPane.add(rdbtnListerLesArtistes);
		
		rdbtnoptionnelProgrammeDu = new JRadioButton("(Optionnel) Programme du spectacle");
		rdbtnoptionnelProgrammeDu.setBounds(6, 181, 232, 23);
		contentPane.add(rdbtnoptionnelProgrammeDu);
		
		btG = new ButtonGroup ();
		btG.add(rdbtnAjouterUnArtiste);
		btG.add(rdbtnAjouterUnNumro);
		btG.add(rdbtnCrerUnArtiste);
		btG.add(rdbtnCrerUnNumro);
		btG.add(rdbtnCrerUnSpectacle);
		btG.add(rdbtnCrerUneSpcialit);
		btG.add(rdbtnListerLesArtistes);
		btG.add(rdbtnListerLesNumros);
		btG.add(rdbtnoptionnelProgrammeDu);
	}
	public void actionPerformed(ActionEvent event) 
	{
		if (event.getSource() == btnValider)
		{
			if (rdbtnCrerUnSpectacle.isSelected())
			{
				Ajout_Spectacle AjtSpect;
				AjtSpect = new Ajout_Spectacle ();
				AjtSpect.setTitle("Ajout d'un spectacle");
				AjtSpect.setBounds(100, 100, 450, 300);
				AjtSpect.setVisible(true);
			}
			if (rdbtnCrerUnNumro.isSelected())
			{
				Ajout_Numero AjtNum;
				AjtNum = new Ajout_Numero ();
				AjtNum.setTitle("Ajout d'un num\u00E9ro");
				AjtNum.setBounds(100, 100, 504, 267);
				AjtNum.setVisible(true);
			}
			if (rdbtnCrerUnArtiste.isSelected())
			{
				Ajout_Artiste AjtArt;
				AjtArt = new Ajout_Artiste ();
				AjtArt.setTitle("Ajout d'un artiste");
				AjtArt.setBounds(100, 100, 503, 320);
				AjtArt.setVisible(true);
			}
			if (rdbtnCrerUneSpcialit.isSelected())
			{
				Ajout_Specialite AjtSpe;
				AjtSpe = new Ajout_Specialite ();
				AjtSpe.setTitle("Ajout d'une sp\u00E9cialit\u00E9");
				AjtSpe.setBounds(100, 100, 450, 300);
				AjtSpe.setVisible (true);
			}
			if (rdbtnAjouterUnNumro.isSelected())
			{
				Ajout_Numero_Spectacle AjtNumSpect = null;
				try {
					AjtNumSpect = new Ajout_Numero_Spectacle ();
				} catch (ClassNotFoundException | SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				AjtNumSpect.setTitle("Ajout d'un num\u00E9ro dans un spectacle");
				AjtNumSpect.setBounds(100, 100, 470, 300);
				AjtNumSpect.setVisible(true);
			}
			if (rdbtnAjouterUnArtiste.isSelected())
			{
				Ajout_ArtisteDansNumero AjtArtNum;
				AjtArtNum = new Ajout_ArtisteDansNumero ();
				AjtArtNum.setTitle("Ajouter un artiste \u00E0 un num\u00E9ro");
				AjtArtNum.setBounds(100, 100, 450, 300);
				AjtArtNum.setVisible(true);
			}
			if (rdbtnListerLesNumros.isSelected())
			{
				Liste_NumerosDansSpectacle AjtNumSpect;
				AjtNumSpect = new Liste_NumerosDansSpectacle ();
				AjtNumSpect.setTitle("Lister les num\u00E9ros d'un spectacle");
				AjtNumSpect.setBounds(100, 100, 450, 300);
				AjtNumSpect.setVisible(true);
			}
			if (rdbtnListerLesArtistes.isSelected())
			{
				ListerArtisteDansSpecialite AjtArtSpeci;
				AjtArtSpeci = new ListerArtisteDansSpecialite ();
				AjtArtSpeci.setTitle("Lister les artistes d'une sp\u00E9cialit\u00E9");
				AjtArtSpeci.setBounds(100, 100, 450, 300);
				AjtArtSpeci.setVisible(true);
			}
			if (rdbtnoptionnelProgrammeDu.isSelected())
			{
				
			}
		}
		if (event.getSource() == btnQuitter)
		{
			dispose();
		}
	}
}
